package cn.apestar.modules.report.paymentWithdrawLog.entity;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Created by admin on 16-6-18.
 */
public class PageResponse<PaymentWithdrawLogAuditResponse> {

    /**
     * 当前页
     */
    private int current_page;

    /**
     * 当前页显示记录数
     */
    private int current_record;

    /**
     * 总页数
     */
    @JsonProperty("total_page")
    private int total_page;

    /**
     * 总记录数
     */
    @JsonProperty("total_record")
    private int total_record;

    public int getCurrent_page() {
        return current_page;
    }

    public void setCurrent_page(int current_page) {
        this.current_page = current_page;
    }

    public int getCurrent_record() {
        return current_record;
    }

    public void setCurrent_record(int current_record) {
        this.current_record = current_record;
    }

    public int getTotal_page() {
        return total_page;
    }

    public void setTotal_page(int total_page) {
        this.total_page = total_page;
    }

    public int getTotal_record() {
        return total_record;
    }

    public void setTotal_record(int total_record) {
        this.total_record = total_record;
    }

    private List<PaymentWithdrawLogAuditResponse> items;

    public PageResponse() {
    }

    public PageResponse(int currentPage, int currentRecord, int totalPage, int totalRecord) {
        this.current_page = currentPage;
        this.current_record = currentRecord;
        this.total_page = totalPage;
        this.total_record = totalRecord;
    }

    public PageResponse(int currentPage, int currentRecord, int totalPage, int totalRecord, List<PaymentWithdrawLogAuditResponse> items) {
        this.current_page = currentPage;
        this.current_record = currentRecord;
        this.total_page = totalPage;
        this.total_record = totalRecord;
        this.items = items;
    }

    public int getOffset() {
        return (current_page - 1) * current_record;
    }

    public void caculate() {
        if (current_record == 0) {
            total_page = 0;
        }

        if (total_record % current_record == 0) {
            total_page = total_record / current_record;
        } else {
            total_page = total_record / current_record + 1;
        }
    }

    public int getTotalPage() {
        caculate();
        return total_page;
    }

    public List<PaymentWithdrawLogAuditResponse> getItems() {
        return items;
    }

    public void setItems(List<PaymentWithdrawLogAuditResponse> items) {
        this.items = items;
    }

    public void setTotalPage(int totalPage) {
        this.total_page = totalPage;
    }
}
